<?php

namespace App\Http\Requests;

class AuthLoginRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'username'=>'required',
            'password' => [
                'required','regex:/^[0-9a-zA-Z]{6,20}$/'
            ]
        ];
    }

    public function messages()
    {
        return [
            'username.required'=>['error_code'=>'F002002','message'=>'username 不能为空！'],
            'password.required'=>['error_code'=>'F003001','message'=>'密码不能为空！'],
            'password.regex'=>['error_code'=>'F003013','message'=>'密码至少6位！'],
        ];
    }
}
